package com.example.mybatisplus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mybatisplus.model.domain.Yq;
import com.example.mybatisplus.mapper.YqMapper;
import com.example.mybatisplus.model.dto.PageDTO;
import com.example.mybatisplus.service.YqService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lxp
 * @since 2024-07-16
 */
@Service
public class YqServiceImpl extends ServiceImpl<YqMapper, Yq> implements YqService {


    @Override
    public Page<Yq> pageList(Yq yq, PageDTO dto) {
        QueryWrapper<Yq> wrapper = new QueryWrapper<>();
        if(StringUtils.isNotBlank((yq.getNameYq()))){
            wrapper.like("name_yq",yq.getNameYq());
        }
        if(StringUtils.isNotBlank((yq.getXiaoquYq()))){
            wrapper.like("xiaoqu_yq",yq.getXiaoquYq());
        }
        Page<Yq> page = new Page<>();
        page.setCurrent(dto.getPageNo()).setSize(dto.getPagesize());
        baseMapper.selectPage(page,wrapper);
        return page;
    }
}
